package com.ruoyi.project.jiaqin.newsfollow.service.impl;

import com.ruoyi.common.utils.text.Convert;
import com.ruoyi.project.jiaqin.newsfollow.domain.NewsFollow;
import com.ruoyi.project.jiaqin.newsfollow.mapper.NewsFollowMapper;
import com.ruoyi.project.jiaqin.newsfollow.service.INewsFollowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.UUID;

/**
 * 新闻关注Service业务层处理
 * 
 * @author LCL
 * @date 2021-10-22
 */
@Service
public class NewsFollowServiceImpl implements INewsFollowService 
{
    @Autowired
    private NewsFollowMapper newsFollowMapper;

    /**
     * 查询新闻关注
     * 
     * @param id 新闻关注ID
     * @return 新闻关注
     */
    @Override
    public NewsFollow selectNewsFollowById(String id)
    {
        return newsFollowMapper.selectNewsFollowById(id);
    }

    /**
     * 查询新闻关注列表
     * 
     * @param newsFollow 新闻关注
     * @return 新闻关注
     */
    @Override
    public List<NewsFollow> selectNewsFollowList(NewsFollow newsFollow)
    {
        return newsFollowMapper.selectNewsFollowList(newsFollow);
    }

    /**
     * 新增新闻关注
     * 
     * @param newsFollow 新闻关注
     * @return 结果
     */
    @Override
    public int insertNewsFollow(NewsFollow newsFollow)
    {
        newsFollow.setId(UUID.randomUUID().toString().replace("-",""));
        newsFollow.setCreated(new Date());
        return newsFollowMapper.insertNewsFollow(newsFollow);
    }

    /**
     * 修改新闻关注
     * 
     * @param newsFollow 新闻关注
     * @return 结果
     */
    @Override
    public int updateNewsFollow(NewsFollow newsFollow)
    {
        return newsFollowMapper.updateNewsFollow(newsFollow);
    }

    /**
     * 删除新闻关注对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteNewsFollowByIds(String ids)
    {
        return newsFollowMapper.deleteNewsFollowByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除新闻关注信息
     * 
     * @param id 新闻关注ID
     * @return 结果
     */
    @Override
    public int deleteNewsFollowById(String id)
    {
        return newsFollowMapper.deleteNewsFollowById(id);
    }

    @Override
    public NewsFollow selectNewsFollowByMemberIdAndNewsId(String memberId, String newsId) {
        return newsFollowMapper.selectNewsFollowByMemberIdAndNewsId(memberId, newsId);
    }
}
